package com.fh.service.cuijimanage;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fh.mapper.loan.UserContactsInfoMapper;
import com.fh.model.loan.UserContactsInfo;

/**
 * Created by Administrator on 2017/5/8/008.
 */
 @Service
  public class UserContactsInfoService {
    
    @Autowired
    private UserContactsInfoMapper userContactsInfoMapper;

    /**
     * 保存新增的联系人
     * @param userContactsInfo
     * @return
     */
    @Transactional
	public int saveUserContactsInfo(UserContactsInfo userContactsInfo) {
		return userContactsInfoMapper.insert(userContactsInfo);
	}
   /**
    * 根据用户ID查询用户联系人
    * @param map
    * @return
    */
	@Transactional(readOnly = true)
   public UserContactsInfo findAllContactsInfoListByUserId(Map<String,Object> map){
	   return userContactsInfoMapper.findContactsInfoByIdAndUid(map);
   }
   /**
    * 根据ID更改联系人信息
    * @param userContactsInfo
    * @return
    */
	 @Transactional
   public int updateByPrimaryKey(UserContactsInfo userContactsInfo){
	   return userContactsInfoMapper.updateByPrimaryKey(userContactsInfo);
   }
	 
   /**
	* 查询该用户的所有的原有联系人
	* @param map
	* @return
	* @author yc
	*/
   @Transactional(readOnly = true) 
   public List<UserContactsInfo> findOldContacts(Map<String,Object> map){
       List<UserContactsInfo> list = userContactsInfoMapper.findOldContacts(map);
       return list;
   }
   /**
    * 修改原有联系人状态
    * 
    * @param info
    */
	public void updateOldContract(UserContactsInfo info) {

		userContactsInfoMapper.updateOldContract(info);
		
	}
    
}
